package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HyReviews;
import com.ruoyi.system.service.IHyReviewsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 影视评论Controller
 * 
 * @author ruoyi
 * @date 2025-06-23
 */
@RestController
@RequestMapping("/system/rev")
public class HyReviewsController extends BaseController
{
    @Autowired
    private IHyReviewsService hyReviewsService;

    /**
     * 查询影视评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:rev:list')")
    @GetMapping("/list")
    public TableDataInfo list(HyReviews hyReviews)
    {
        startPage();
        List<HyReviews> list = hyReviewsService.selectHyReviewsList(hyReviews);
        return getDataTable(list);
    }

    /**
     * 导出影视评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:rev:export')")
    @Log(title = "影视评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HyReviews hyReviews)
    {
        List<HyReviews> list = hyReviewsService.selectHyReviewsList(hyReviews);
        ExcelUtil<HyReviews> util = new ExcelUtil<HyReviews>(HyReviews.class);
        util.exportExcel(response, list, "影视评论数据");
    }

    /**
     * 获取影视评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rev:query')")
    @GetMapping(value = "/{reviewsId}")
    public AjaxResult getInfo(@PathVariable("reviewsId") Long reviewsId)
    {
        return success(hyReviewsService.selectHyReviewsByReviewsId(reviewsId));
    }

    /**
     * 新增影视评论
     */
    @PreAuthorize("@ss.hasPermi('system:rev:add')")
    @Log(title = "影视评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HyReviews hyReviews)
    {
        return toAjax(hyReviewsService.insertHyReviews(hyReviews));
    }

    /**
     * 修改影视评论
     */
    @PreAuthorize("@ss.hasPermi('system:rev:edit')")
    @Log(title = "影视评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HyReviews hyReviews)
    {
        return toAjax(hyReviewsService.updateHyReviews(hyReviews));
    }

    /**
     * 删除影视评论
     */
    @PreAuthorize("@ss.hasPermi('system:rev:remove')")
    @Log(title = "影视评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reviewsIds}")
    public AjaxResult remove(@PathVariable Long[] reviewsIds)
    {
        return toAjax(hyReviewsService.deleteHyReviewsByReviewsIds(reviewsIds));
    }
}
